﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using Aij1.Utils;

namespace Aij1.BLL
{
    public class Config
    {
        public static string UploadDir
        {
            get
            {
                string url = string.Format("{0}/{1:yyMM}/", ConfigurationManager.AppSettings["UploadDir"], DateTime.Today);
                string path = HttpContext.Current.Server.MapPath(url);
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                return url;
            }
        }

        static string companyName;
        public static string CompanyName
        {
            get
            {
                if (companyName == null)
                {
                    companyName = ConfigurationManager.AppSettings["CompanyName"];
                }
                if (String.IsNullOrEmpty(companyName))
                {
                    companyName = "爱+1亲子摄影馆";
                }
                return companyName;
            }
        }

        static string companyAddress;
        public static string CompanyAddress
        {
            get
            {
                if (companyAddress == null)
                {
                    companyAddress = ConfigurationManager.AppSettings["CompanyAddress"];
                }
                if (String.IsNullOrEmpty(companyAddress))
                {
                    companyAddress = "武汉市洪山区雄楚大道添美城市广场9栋1单元1002";
                }
                return companyAddress;
            }
        }

        static string companyTel;
        public static string CompanyTel
        {
            get
            {
                if (companyTel == null)
                {
                    companyTel = ConfigurationManager.AppSettings["CompanyTel"];
                }
                if (String.IsNullOrEmpty(companyTel))
                {
                    companyTel = "027-87523071";
                }
                return companyTel;
            }
        }
        static string companyMobile;
        public static string CompanyMobile
        {
            get
            {
                if (companyMobile == null)
                {
                    companyMobile = ConfigurationManager.AppSettings["CompanyMobile"];
                }
                if (String.IsNullOrEmpty(companyMobile))
                {
                    companyMobile = "13274145681";
                }
                return companyMobile;
            }
        }

        static string companyQQ;
        public static string CompanyQQ
        {
            get
            {
                if (companyQQ == null)
                {
                    companyQQ = ConfigurationManager.AppSettings["CompanyQQ"];
                }
                if (String.IsNullOrEmpty(companyQQ))
                {
                    companyQQ = "984160960";
                }
                return companyQQ;
            }
        }

        static string keywords;
        public static string Keywords
        {
            get
            {
                if (keywords == null)
                {
                    keywords = ConfigurationManager.AppSettings["Keywords"];
                }
                if (String.IsNullOrEmpty(keywords))
                {
                    keywords = "武汉光谷儿童摄影,武汉洪山区儿童摄影,武汉光谷爱+1亲子摄影,武汉光谷百日照,武汉新技术开发区儿童摄影,武汉光谷周岁照,武汉光谷亲子照,儿童成长照,武汉光谷全家福,武汉光谷孕妇照,武汉光谷上门拍摄,武汉光谷实景拍摄,武汉光谷韩式摄影";
                }
                return keywords;
            }
        }

        static string description;
        public static string Description
        {
            get
            {
                if (description == null)
                {
                    description = ConfigurationManager.AppSettings["Description"];
                }
                if (String.IsNullOrEmpty(description))
                {
                    description = "武汉光谷爱+1亲子摄影馆,主营：亲子照、满月照、百天照、周岁照、孕妇照、全家福、个性写真等,TEL：027-87523071 .近千套儿童摄影服饰.服装当场消毒.最新优惠活动.武汉光谷亲子摄影,武汉光谷亲子摄影工作室.";
                }
                return description;
            }
        }

        public static string GetAlbumSnapShotUrl(string albumUrl)
        {
            string url = String.Format("{0}SnapShot/", albumUrl);
            string path = HttpContext.Current.Server.MapPath(url);
            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }
            return url;
        }

        static int fileIndex = 0;
        public static string GetUniqueName()
        {
            return string.Format("{0:ddHHmmss}{1:000}", DateTime.Now, fileIndex++);
        }

        static int orderIndex = 0;
        public static string GetUniqueOrderNo()
        {
            if (orderIndex == 0)
            {
                string s = CommOp.ToStr(DBHelper.DefaultHelper.ExecGetObject("SELECT MAX(OrderNo) FROM B_Order"));
                if (!String.IsNullOrEmpty(s)) s = s.Substring(s.Length - 3);
                orderIndex = CommOp.ToInt(s);
            }
            return string.Format("S{0:yyMMdd}{1:000}", DateTime.Now, ++orderIndex);
        }

    }
}